Use Test.createTestingModule() to create an isolated module, replace real providers with jest mock objects using useValue, compile the module, then retrieve the service under test with module.get(). This allows testing service logic without needing a real database, HTTP client, or other infrastructure.
Use useValue with jest.fn() mocks — avoids spinning up real infrastructure.
module.get(Token) retrieves the instantiated provider from the test container.
Assign the mock to a variable so you can configure return values per test with mockResolvedValue or mockReturnValue.
For providers from imported modules use .overrideProvider(Token).useValue(mock) instead of redeclaring them.